/*  mudmap - A tool to create and organize user side maps for MUD games
 *  Copyright (C) 2012  Neop (aka moemneop, email: mneop@web.de)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include "tk.h"

namespace tk{

/// float zu int runden
int round_to_int(float a){
    if(a >= 0){
        return (int) a + ((a - (int) a) >= 0.5 ? 1 : 0);
    } else {
        return (int) a - ((a - (int) a) <= -0.5 ? 1 : 0);
    }
}

/// Nachkommazahl beim float zu int runden
float round_r(float a){
    return a - (int) a;
}

/// Abrunden
int round_down(float a){
    if(a >= 0) return (int) a;
    else return (int) a - 1;
}

}
